package com.hzspace.springsessiondataredis;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@SpringBootApplication
public class SpringSessionDataRedisApplication {

  public static void main(String[] args) {
    SpringApplication.run(SpringSessionDataRedisApplication.class, args);
  }

  @Value("${server.port}")
  Integer port;
  @GetMapping("/set")
  public String set(HttpSession session) {
    session.setAttribute("user", "hzspace");
    return String.valueOf(port);
  }
  @GetMapping("/get")
  public String get(HttpSession session) {
    return session.getAttribute("user") + ":" + port;
  }

}
